class MyLocalStorage {
  public static instance: MyLocalStorage;

  private constructor() {}

  setItem(key: string, value: any) {
    localStorage.setItem(key, JSON.stringify(value));
  }

  getItem(key: string) {
    const value = localStorage.getItem(key);
    return value !== null ? JSON.parse(value) : null;
  }

  public static getInstance() {
    if (!this.instance) {
      this.instance = new MyLocalStorage();
    }
    return this.instance;
  }
}
